package com.lovo.middleman.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.middleman.bean.SupplierBean;
import com.lovo.middleman.service.ISupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/supplier")
public class SupplierController {

    @Autowired
    ISupplierService iSupplierService;

    /**
     * 分页
     * @param curPage
     * @param pageSize
     * @param supplierName
     * @param supplierBusinessScope
     * @return
     */
    @RequestMapping("/getSupplierPage")
    public Page<SupplierBean> getSupplierPage(int curPage,
                                          int pageSize,
                                          String supplierName,
                                          String supplierBusinessScope){
        Page<SupplierBean> page  = iSupplierService.selectSupplierBeanPageItem(curPage, pageSize, supplierName, supplierBusinessScope);

        return page;
    }

    /**
     * 查询单个
     * @param supplierId
     * @return
     */
    @RequestMapping("/getSupplierBean")
    public SupplierBean getSupplierBean(int supplierId){
        return iSupplierService.selectSupplierBeanById(supplierId);
    }

    /**
     * 修改
     * @param supplierBean
     */
    @RequestMapping("/updateSupplierBean")
    public void updateSupplierBean(@RequestBody SupplierBean supplierBean){
        iSupplierService.updateSupplier(supplierBean);
    }

    /**
     * 添加
     * @param supplierBean
     */
    @RequestMapping("/addSupplierBean")
    public void addSupplierBean(@RequestBody SupplierBean supplierBean){
        iSupplierService.addSupplier(supplierBean);
    }
}
